from typing import Dict, Optional, Type, Union
from http_client import HttpClient
from async_http_client import AsyncHttpClient

class HttpClientFactory:
    @staticmethod
    def create(
        async_mode: bool = False,
        base_url: str = "",
        timeout: int = 30,
        max_retries: int = 3,
        token: Optional[str] = None,
        headers: Optional[Dict[str, str]] = None
    ) -> Union[HttpClient, AsyncHttpClient]:
        """
        根据模式创建HTTP客户端
        :param async_mode: 是否使用异步模式
        :param base_url: 基础URL
        :param timeout: 超时时间(秒)
        :param max_retries: 最大重试次数
        :param token: 认证令牌
        :param headers: 自定义请求头
        :return: HTTP客户端实例
        """
        if async_mode:
            return AsyncHttpClient(
                base_url=base_url,
                timeout=timeout,
                max_retries=max_retries,
                token=token,
                headers=headers
            )
        else:
            return HttpClient(
                base_url=base_url,
                timeout=timeout,
                max_retries=max_retries,
                token=token,
                headers=headers
            ) 